Add preview deployment workflow for pull requests#3
Merged
Conversation
Adds a GitHub Actions workflow that deploys PR previews to Cloudflare Pages, matching the same mechanism used in the presentations repo. On PR open/update it builds the Docusaurus site and deploys it, commenting a preview URL on the PR. On PR close it cleans up the preview deployments. Requires CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID repository secrets. https://claude.ai/code/session_01P7QZZ9gtBDbS6BeoLdrPMt
Contributor
Preview DeploymentThis PR has been deployed for preview:
|
Wrap long lines to stay within 80 character limit and add YAML document start marker to pass super-linter checks. https://claude.ai/code/session_01P7QZZ9gtBDbS6BeoLdrPMt
Checkov (run by super-linter) requires workflows to declare explicit top-level permissions rather than relying on defaults. Add minimal permissions blocks to linter, test deploy, and deploy workflows. https://claude.ai/code/session_01P7QZZ9gtBDbS6BeoLdrPMt
Add yamllint disable-line directives for the truthy rule on `on:` keys in all GitHub Actions workflow files. The `on` key triggers a yamllint truthy warning which super-linter treats as an error. https://claude.ai/code/session_01P7QZZ9gtBDbS6BeoLdrPMt
- Apply Prettier formatting to all workflow YAML files - Add USER instruction to Dockerfile (CKV_DOCKER_3) - Add HEALTHCHECK instruction to Dockerfile (CKV_DOCKER_2) https://claude.ai/code/session_01P7QZZ9gtBDbS6BeoLdrPMt
- Remove gh-pages-test-deploy.yml since preview.yml already validates the build on every PR - Add commit SHA to preview deployment comment for traceability - Add page-limit safety valve (max 50) in cleanup pagination - Move permissions to job-level for least privilege - Drop unnecessary issues: write permission https://claude.ai/code/session_01P7QZZ9gtBDbS6BeoLdrPMt
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a GitHub Actions-based preview deployment pipeline for pull requests using Cloudflare Pages, and updates existing CI/CD workflows to align with the new approach.
Changes:
- Added a new PR-triggered workflow to build, deploy, comment the preview URL, and clean up Cloudflare Pages preview deployments.
- Updated existing GitHub Actions workflows (lint + GitHub Pages deploy) and removed the older GitHub Pages test-deploy workflow.
- Updated the Docker image configuration to run as a non-root user and added a container healthcheck.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
Dockerfile |
Runs container as node user and adds a healthcheck (but introduces a likely runtime permission issue). |
.github/workflows/preview.yml |
New Cloudflare Pages preview deploy + PR comment + cleanup workflow (has permission + pagination/commit-SHA issues). |
.github/workflows/linter.yml |
Tweaks workflow YAML and adds explicit permissions. |
.github/workflows/gh-pages-test-deploy.yml |
Removes the prior PR build-only workflow. |
.github/workflows/gh-pages-deploy.yml |
Adds explicit permissions (currently breaks deployment by making contents read-only). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Dockerfile: add --chown=node:node to COPY so /app is writable as node - preview.yml: add issues: write permission for PR comment API calls - preview.yml: use github.paginate() for listComments to handle >30 comments - preview.yml: use PR head SHA instead of merge commit SHA - gh-pages-deploy.yml: grant contents: write for gh-pages branch push https://claude.ai/code/session_01P7QZZ9gtBDbS6BeoLdrPMt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a GitHub Actions workflow that automatically deploys pull requests to Cloudflare Pages for preview testing, and cleans up deployments when PRs are closed.
Key Changes
.github/workflows/preview.ymlthat handles preview deploymentsImplementation Details
pr-{PR_NUMBER}for easy identificationCLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDsecrets to be configuredhttps://claude.ai/code/session_01P7QZZ9gtBDbS6BeoLdrPMt